package com.kefu.chat.vo;

import cn.hutool.core.bean.BeanUtil;
import com.kefu.chat.model.ChatPoster;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

@Data
public class ChatPosterInsertVo extends AbstractInsertVo<ChatPoster> {
    @NotEmpty
    @ApiModelProperty(value = "广告名称")
    private String name;
    @ApiModelProperty(value = "广告内容")
    private String content;
    @ApiModelProperty(value = "广告描述")
    private String remark;
    @ApiModelProperty(value = "跳转地址")
    private String url;
    @Override
    public ChatPoster convert() {
        ChatPoster info = BeanUtil.toBean(this, ChatPoster.class);
        KefuContext context = KefuContext.getKefuContext();
        info.setTenantId(context.getTenantId());
        info.setUpdateTime(context.getNow());
        info.setCreateTime(context.getNow());
        info.setCreateUser(context.getUserId());
        info.setUpdateUser(context.getUserId());
        info.setCreateName(context.getUserName());
        info.setUpdateName(context.getUserName());
        return info;
    }
}
